import logo from './logo.svg';
import './App.css';
import {parseOfdDocument, renderOfd, setMaxPageScale, setPageScale} from "ofd.js";

function App() {
    return (
        <div className="App">
            <input type="file"
                   id="avatar" name="ofd文件"
                   accept="ofd" onChange={(event) => {
                readFile(event)
            }}></input>
            <div id="content">
            </div>
        </div>
    );
}

function readFile(event) {
    parseOfdDocument({
        ofd: event.target.files[0],
        success(res) {
            console.log(res)
            const scale = (960 / 210).toFixed(1);
            setMaxPageScale(scale * 4);
            setPageScale(scale);
            const divs = renderOfd(res.data.ofd, 0);
            let contentDiv = document.getElementById('content');
            contentDiv.innerHTML = '';
            for (const div of divs) {
                contentDiv.appendChild(div)
            }
        }
    })
}

export default App;
